package orchestration.android.execution.tasks;

import android.content.Intent;
import orchestration.android.RunExecutionActivity;
import orchestration.android.execution.exceptions.TaskExecutionException;
import orchestration.persistence.exceptions.UnsupportedTypeException;

/**
 * @author  <a href="mailto:car.ferrarini@gmail.com">Carlo Ferrarini</a>
 */
public class SendBroadcastTask extends AndroidTask{

	/**
	 * @uml.property  name="intent"
	 */
	private Intent intent;
	
	public SendBroadcastTask(String id) {
		super(id);
	}
	

	/**
	 * @return
	 * @uml.property  name="intent"
	 */
	public Intent getIntent() {
		return intent;
	}


	/**
	 * @param intent
	 * @uml.property  name="intent"
	 */
	public void setIntent(Intent intent) {
		this.intent = intent;
	}


	@Override
	public void onExecute(RunExecutionActivity atl) throws TaskExecutionException {
		try {
			fillIntentExtras(atl,intent);
		} catch (UnsupportedTypeException e) {
			throw new TaskExecutionException(e);
		}
		atl.sendBroadcast(intent);
	}

}
